package cn.lxb.emall.account.facade;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;

import cn.lxb.emall.account.api.AccountFacade;

@RestController
public class AccountFacadeImpl implements AccountFacade {
	@Value("${server.port}")
	int port;

	@Override
	public String getAccount(String name) {
		return "ac-" + name;
	}

	@Override
	public String getAccountTimeout(String name) {
		try {
			Thread.sleep(10000L);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return "ac-" + name;
	}

	@Override
	public String getAccount500(String name) {
		throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "test500");
	}

	@Override
	public String getAccount404(String name) {
		throw new ResponseStatusException(HttpStatus.NOT_FOUND, "test404");
	}

}
